package greedyAlgorithm;

import org.junit.Test;

/**
 * @author kunkun
 * @className LeetCode_55
 * @Description ...
 * @date 2025/3/18 9:41
 */
public class LeetCode_55 {

    //通过覆盖范围求解
    public boolean canJump(int[] nums) {
        if (nums.length==1){
            return true;
        }
        int rightLimit = -1,i=0;
        do{
            if (rightLimit>= nums.length-1){
                return true;
            }
            if (nums[i]+i>rightLimit){
                rightLimit = nums[i]+i;
            }
            i++;
        }while (i<=rightLimit);
        return false;
    }



}
